home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 May / CHIP Mayıs 1997.iso / cont / web / winsock / virc / objectvs.txt < prev    next >
Encoding:
Text File  |  1997-01-20  |  34.8 KB  |  952 lines

  1. ObjectViRCScript Documentation (for ViRC '96 0.82a and above) - Revision 2a
  2. ===========================================================================
  3.  
  4. Introduction
  5. ============
  6.  
  7. What is ObjectViRCScript? ObjectViRCScript is a set of object-based extensions
  8. to the main ViRCScript language, adding a class/property/event model to
  9. ViRCScript, much as C++ adds a similar model to C.
  10.  
  11. Anyone who has programmed in Delphi before will feel instantly familiar with
  12. OVS - it uses Delphi's class library!! This was facilitated by Delphi's very
  13. comprehensive RTTI system which allows sufficient data to be extracted from
  14. classes and so forth at runtime to make programming the ObjectViRCScript
  15. interpreter relatively simple - OVS adds only about 1200 lines of code to the
  16. main ViRCScript interpreter.
  17.  
  18. What does ObjectViRCScript add?
  19. -------------------------------
  20.  
  21. OVS adds New and Destroy to create and destroy class objects, a new @p
  22. statement to set properties, and a $prop function to get properties. Also added
  23. is the ability to call object methods, either as statements or as functions to
  24. return values. New MAPOBJECT function and UNMAPOBJECT statement added to enable
  25. customization of ViRC '96's GUI (server windows, channel windows etc.). Adds
  26. WITH/ENDWITH for making setting multiple properties of an object easier.
  27. ADDTOSETPROP and REMOVEFROMSETPROP commands for dealing with objects' set
  28. properties.
  29.  
  30. What's new in this release of ObjectViRCScript?
  31. -----------------------------------------------
  32.  
  33. New in 0.82: support for enumerated and set properties, many object methods,
  34. many new classes supported (including the TSockets class for writing sockets
  35. applications in ViRCScript, and TTimer for making timers), and
  36. MAPOBJECT/UNMAPOBJECT for customizing V96's built-in windows. New WITH/ENDWITH
  37. statements. ADDTOSETPROP/REMOVEFROMSETPROP statements.
  38.  
  39. New in 0.82a: a few more implemented methods documented, corrected many
  40. documentation inaccuracies (esp. in TSockets documentation).
  41.  
  42. What's currently wrong with ObjectViRCScript?
  43. ---------------------------------------------
  44.  
  45. This is a difficult one ... not all methods of all Delphi objects are currently
  46. supported, although support will improve greatly in future versions.
  47.  
  48. ObjectViRCScript extension details
  49. ==================================
  50.  
  51. NEW function
  52. ------------
  53.  
  54. Usage: $new(class [ownedby object])
  55.  
  56. Creates a new object of type class, and returns an instance handle. Class can
  57. be any of the Delphi VCL classes, for example, TForm, TEdit, TButton, and so
  58. forth. If the optional ownedby object parameter is specified, the object's
  59. owner is set to that parameter. If you're creating a TForm, which has no owner
  60. (actually ViRC '96 itself is the owner), you must leave this parameter off -
  61. forms owning other forms does not make sense. Note: all objects are created
  62. invisible. To show them, you need to change their Visible property (see the
  63. @P statement below). Examples:
  64.  
  65. The following code makes a new TForm object and assigns its instance handle to
  66. the $form variable. Notice that
  67.  
  68.         @ $form = $new(TForm)
  69.  
  70. Once the form has been created and assigned to $form, the following code adds a
  71. button to the form:
  72.  
  73.         @ $button = $new(TButton ownedby $form)
  74.  
  75. DESTROY command
  76. ---------------
  77.  
  78. Usage: Destroy object
  79.  
  80. Destroys object, along with all the objects it owns, freeing all the memory
  81. associated with the objects. You should always use DESTROY to destroy any
  82. object you have created to conserve memory. Note that, if you have a TForm
  83. which owns a number of other controls, you only have to call DESTROY once for
  84. the form object, as all the controls it owns will be automatically destroyed as
  85. well. Example:
  86.  
  87. To destroy the form object $form and all controls that it owns:
  88.  
  89.         Destroy $form
  90.  
  91. DESTROY does _NOT_ deallocate the variable specified, only the object itself.
  92. Therefore, unless you're storing the object handle in a local variable, you
  93. should deallocate the variable after using the DESTROY command (e.g. -@ $form).
  94.  
  95. Note that Delete is synonymous with Destroy - you can use either.
  96.  
  97. @P command
  98. ----------
  99.  
  100. Usage: @p $object.Property = Value
  101.  
  102. Assigns Value to $object's Property property. For example, to show the form
  103. object $form, change its caption, and make it visible, you could do:
  104.  
  105.         @p $form.Caption = This is a test!!
  106.         @p $form.Visible = True
  107.  
  108. Please note that only a subset of Delphi's types are currently supported for
  109. properties. They are: integers, strings, booleans (use 1 and 0 for True and
  110. False respectively), enums, sets, and objects. Floats and variants are
  111. currently NOT supported, although this will probably change in future versions
  112. of OVS. For example, to set the active control on the form object $form to
  113. the button object $button, use:
  114.  
  115.         @p $form.ActiveControl = $button
  116.  
  117. You can set enum properties either by name, or by index. You will probably
  118. prefer to set them by name!! For example, the 2 lines below are equivalent,
  119. causing the $edit object to align itself with the bottom of its parent form.
  120.  
  121.         @p $edit.Align = 2
  122.         @p $edit.Align = alBottom
  123.  
  124. Of course, the latter is far more self-explanatory.
  125.  
  126. You can also retrieve set properties. Set properties are similar to enums,
  127. except that multiple elements within the set can be set at once. A very common
  128. set property (possibly the only one you will ever use) is TForm.BorderIcons.
  129. This controls what icons are present in a form's border. The BorderIcons set
  130. may contain any combination of biSystemMenu, biMinimize, and biMaximize. Set
  131. properties MUST be included in []'s (even if there is only one member (or even
  132. no members) in the set) and multiple elements must be separated by , (a comma).
  133. Examples:
  134.  
  135.         // Makes the form's border contain only a system menu icon
  136.         @p $form.BorderIcons = [biSystemMenu]
  137.  
  138.         // Show all the icons in a form's border
  139.         @p $form.BorderIcons = [biSystemMenu,biMinimize,biMaximize]
  140.  
  141.         // Show no icons in the form's border
  142.         @p $form.BorderIcons = []
  143.  
  144. You can also add or remove specific values from a set. See the ADDTOSETPROP and
  145. REMOVEFROMSETPROP commands below for more information.
  146.  
  147. In addition, OBJECT EVENTS may be set with @p. This can be illustrated with
  148. some very simple examples:
  149.  
  150.         @p $button.OnClick = MessageBox You clicked me!!
  151.  
  152.         @p $form.OnClose = Beep
  153.  
  154. If you want to execute more than one command in response to an object event,
  155. define an alias and call that, for example:
  156.  
  157.         @p $closebutton.OnClick = CLOSEBUTTON_CLICK
  158.  
  159.         Alias CLOSEBUTTON_CLICK
  160.           MessageBox I'll now close the form!!
  161.           Destroy $form
  162.         EndAlias
  163.  
  164. In addition, with some events, ViRC '96 will pass in extra information in the
  165. form of local variables. In fact, V96 always passes in $Sender, which is the
  166. object that caused the event. Thus you can create one alias which handles
  167. events from a number of objects of different types. The following events are
  168. supported:
  169.  
  170.         Mouse events
  171.         ------------
  172.  
  173.         Event names: OnMouseUp, OnMouseDown
  174.         Variables passed in: $Button - button pressed. Can be mbLeft, mbRight
  175.                                        or mbMiddle.
  176.                              $X      - X coordinate of where the mouse is.
  177.                              $Y      - Y coordinate of where the mouse is.
  178.  
  179.         Mouse move events
  180.         -----------------
  181.  
  182.         Event names: OnMouseMove
  183.         Variables passed in: $X      - X coordinate of where the mouse is.
  184.                              $Y      - Y coordinate of where the mouse is.
  185.  
  186.         Key events
  187.         ----------
  188.  
  189.         Event names: OnKeyUp, OnKeyDown
  190.         Variables passed in: $Key    - The scan code for the key pressed. You
  191.                                        can modify this value in your
  192.                                        OnKeyUp/OnKeyDown events to simulate as
  193.                                        if a different key were pressed. For
  194.                                        example, if you wish to nullify a key
  195.                                        press, set $Key to 0 in your code.
  196.  
  197.         Key press events
  198.         ----------------
  199.  
  200.         Event names: OnKeyPress
  201.         Variables passed in: $Key    - The key pressed (e.g. A, 0, & etc). You
  202.                                        can change this value in your
  203.                                        OnKeyUp/OnKeyDown events to simulate as
  204.                                        if a different key were pressed.
  205.  
  206. Drag-and-drop events are also supported, although their usage is rather
  207. complicated, and I will refrain from documenting them until they work well.
  208.  
  209. ADDTOSETPROP command
  210. --------------------
  211.  
  212. Usage: AddToSetProp object.property set
  213.  
  214. Combines set with the set property object.property. This is used to add values
  215. to a set. For example, this code will display the minimize icon on a form's
  216. border by adding the item biMinimize to the BorderIcons set:
  217.  
  218.         AddToSetProp $form.BorderIcons [biMinimize]
  219.  
  220. Note that if biMinimize is already present in the set, the second addition will
  221. have no effect, in other words, ADDTOSETPROP will only add an item to a set if
  222. it isn't already in the set. You can add multiple items to a set as well.
  223. Example:
  224.  
  225.         AddToSetProp $form.BorderIcons [biMaximize,biMinimize]
  226.  
  227. ADDTOSETPROP is an efficient wrapper around the standard VS ADDTOSET function.
  228. For example:
  229.  
  230.         AddToSetProp $form.BorderIcons [biMaximize,biMinimize]
  231.  
  232. Is equivalent to this:
  233.  
  234.         @p $form.BorderIcons = $AddToSet($prop($form.BorderIcons) [biMaximize,biMinimize])
  235.  
  236. REMOVEFROMSETPROP command
  237. -------------------------
  238.  
  239. Usage: AddToSetProp object.property set
  240.  
  241. Removes any elements from object.property that are also present in set. For
  242. example, the following code will remove the minimize icon from a form's border
  243. by removing the biMinimize element from the set:
  244.  
  245.         RemoveFromSetProp $form.BorderIcons [biMinimize]
  246.  
  247. You can remove multiple items from a set at once (see above). Attempting to
  248. remove an item from a set which isn't in the set will have no effect.
  249.  
  250. REMOVEFROMSETPROP is an efficient wrapper around the standard VS REMOVEFROMSET
  251. function. For example:
  252.  
  253.         RemoveFromSetProp $form.BorderIcons [biMaximize,biMinimize]
  254.  
  255. Is equivalent to this:
  256.  
  257.         @p $form.BorderIcons = $RemoveFromSet($prop($form.BorderIcons) [biMaximize,biMinimize])
  258.  
  259. WITH/ENDWITH statement
  260. ----------------------
  261.  
  262. (should this be in VSCRIPT.TXT instead? Or as well?)
  263.  
  264. Usage: With command
  265.          ...
  266.        EndWith
  267.  
  268. This very useful statement makes setting multiple object properties (for
  269. example) very easy. Basically, command is prepended to every line in the
  270. WITH/ENDWITH block before execution. Example (from WEBSERV.VSC):
  271.  
  272.         @ $webform = $new(TTabbedForm)
  273.         With @p $webform.
  274.              Left = 20
  275.              Top = 20
  276.              Width = 300
  277.              Height = 300
  278.              FormStyle = fsStayOnTop
  279.              Caption = ObjectViRCScript Web Server Example
  280.              TabCaption = Web server
  281.              Visible = True
  282.         EndWith
  283.  
  284. This would be equivalent to:
  285.  
  286.         @ $webform = $new(TTabbedForm)
  287.         @p $webform.Left = 20
  288.         @p $webform.Top = 20
  289.  
  290.         etc.
  291.  
  292. As can be seen, WITH makes setting multiple object properties very simple.
  293. Although this is the use WITH was designed for, it's possible to use it without
  294. objects. For example, you can use this to make outputting multiple lines of
  295. text to a query window very simple:
  296.  
  297.  
  298.         With TextOut > TextQuery clBlue $null
  299.              Hello!!
  300.              This is a very good way ...
  301.              ... to add lots of lines of text at once ...
  302.              ... to a window.
  303.         EndWith
  304.  
  305. The $null is required to ensure that the space after clBlue is not removed by
  306. the parser.
  307.  
  308. PROP function
  309. -------------
  310.  
  311. Usage: $prop($object.Property)
  312.  
  313. Returns the property Property of $object. For example, to retrieve the contents
  314. of a TEdit control, you could use:
  315.  
  316.         @ $x = $prop($edit.Text)
  317.  
  318. The PROP function can currently return integer, string, boolean, enum, and
  319. object properties. Other Delphi property types aren't supported yet, but they
  320. should be in future versions of OVS.
  321.  
  322. OVSVER variable
  323. ---------------
  324.  
  325. Usage: $ovsver
  326.  
  327. This variable contains the ObjectViRCScript version number. V96 0.82 and above
  328. return an ObjectViRCScript version number of 2. The presence of this variable
  329. is useful, as it allows you to test in your script whether the user is running
  330. an ObjectViRCScript-capable version of ViRC '96 or not, for example:
  331.  
  332. if !($ovsver)
  333.    MessageBox This script requires ViRC '96 0.80 or higher with ObjectViRCScript to function.
  334.    Halt
  335. endif
  336.  
  337. MAPOBJECT function
  338. ------------------
  339.  
  340. Usage: $mapobject(window[:control])
  341.  
  342. This is possibly THE most powerful function in ObjectViRCScript. What it does
  343. is to return an ObjectViRCScript object handle for any built-in ViRC '96
  344. window. You can then add controls to it or change properties as if it were an
  345. object which you have created yourself.
  346.  
  347. This function is designed primarily to be used in the <OnCreateWindow> event,
  348. which is fired whenever a new channel window or server window is created. Two
  349. parameters are passed to the event: $0 is the class of the window created
  350. (TServerForm or TChannelForm), and $1 is the standard name of the window. So,
  351. server windows always have a name of . (period), channel windows have names of
  352. #channel, and so forth.
  353.  
  354. For example, this very simple example changes the colour of the text entry area
  355. of server windows to a random colour whenever a new one is opened. Note that,
  356. with server windows, $1 is always . (period), so you could replace
  357. $mapobject($1:tbServerText) with $mapobject(.:tbServerText).
  358.  
  359. Event <OnCreateWindow> "TServerForm"
  360.   @ $servertext = $mapobject($1:tbServerText)
  361.   @p $servertext.Color = $rand($FFFFFF)
  362.   UnmapObject $servertext
  363. EndEvent
  364.  
  365. Another example: to make text entry areas in channel windows appear at the top
  366. of the window rather than the bottom, you could use:
  367.  
  368. Event <OnCreateWindow> "TChannelForm"
  369.   @ $chanentry = $mapobject($1:EntryPanel)
  370.   @p $chanentry.Align = alTop
  371.   UnmapObject $chanentry
  372. EndEvent
  373.  
  374. Really, knowledge of all the names of the controls on server and channel
  375. windows is needed, so I might release the source .DFM files for those forms so
  376. anyone with Delphi can find the names themselves. However, this should get
  377. you started:
  378.  
  379. Server window only
  380. ------------------
  381.  
  382.         tbServCommand   - TEdit entry box where the user types commands
  383.         tbServerText    - TRichEdit where server text appears
  384.  
  385. Channel window only
  386. -------------------
  387.  
  388.         NamesPanel      - TPanel containing lvNames
  389.         tbChannelText   - TRichEdit where channel text appears
  390.         lvNames         - TListView where the channel nick list is
  391.                           *** NOTE *** TListView is not fully supported by
  392.                           OVS yet. However, you can read/write a TListView's
  393.                           ItemText and ItemIndex properties to fetch the
  394.                           currently-selected nick in a channel nicks list, for
  395.                           example (or you could use the regular ViRCScript
  396.                           function $selectednick() for this, which is probably
  397.                           a LOT simpler!! :)
  398.  
  399. Both windows
  400. ------------
  401.  
  402.         MainPanel       - TPanel containing text output box
  403.         EntryPanel      - TPanel containing entry box
  404.         WholePanel      - TPanel containing MainPanel and EntryPanel
  405.         ToolbarPanel    - TPanel containing toolbar
  406.  
  407. The MAPOBJECT function can also be used to return an internal ViRC '96 form,
  408. for example, the client setup form. The list of supported forms is as follows:
  409.  
  410.         !AboutBox
  411.         !Aliases
  412.         !ChannelBox
  413.         !ChannelList
  414.         !EditXDCCPack
  415.         !EventManager
  416.         !FingerClientDialog
  417.         !TipForm
  418.         !IRCServers
  419.         !UserSetup
  420.         !ListFilter
  421.         !LoadingScript
  422.         !Main
  423.         !MenuEditor
  424.         !PortScanner
  425.         !ResumeDlg
  426.         !Links
  427.         !VSWizard
  428.         !WHOIS
  429.         !WhoList
  430.  
  431. You can thus add controls to any of these forms. For example:
  432.  
  433.         @ $aliasform = $mapobject(!Aliases)
  434.         @ $button = $new(TButton ownedby $aliasform)
  435.  
  436. In addition, the !UserSetup form's page control is called SetupPages. Thus you
  437. can add your own tab to ViRC '96's client setup dialog!! For example, this
  438. code will add a new tab sheet to the client setup dialog which contains one
  439. button:
  440.  
  441.         @ $SetupPages = $mapobject(!UserSetup:SetupPages)
  442.  
  443.         @ $NewTabSheet = $new(TTabSheet ownedby $SetupPages)
  444.         With @p $NewTabSheet.
  445.              PageControl = $SetupPages
  446.              Caption = Test tab
  447.         EndWith
  448.  
  449.         @ $NewButton = $new(TButton ownedby $NewTabSheet)
  450.         With @p $NewButton.
  451.              Left = 20
  452.              Top = 36
  453.              Width = 73
  454.              Height = 65
  455.              Caption = &Beep!!
  456.              OnClick = Beep
  457.         EndWith
  458.  
  459.         $SetupPages.RefreshTabs
  460.         UnmapObject $SetupPages
  461.  
  462. If you do add pages to V96's client setup dialog, you must call the RefreshTabs
  463. method to ensure that the pages are refreshed properly, otherwise you will
  464. experience visual problems. You only need to call RefreshTabs on V96's client
  465. setup dialog, never on your own tab controls.
  466.  
  467. UNMAPOBJECT command
  468. -------------------
  469.  
  470. Usage: UnmapObject object
  471.  
  472. The MAPOBJECT function creates a ViRCScript object handle representing a
  473. built-in V96 object. You must use the UNMAPOBJECT command to remove the object
  474. handle when you have finished using it, otherwise, the object handle will be
  475. left in memory (each object handle only takes 4 bytes, but these can add up).
  476. UNMAPOBJECT, unlike DESTROY, does not harm the underlying object, but merely
  477. removes its ObjectViRCScript handle.
  478.  
  479. Special objects
  480. ===============
  481.  
  482. On startup, ViRC '96 creates the special object handle 0 which represents the
  483. main ViRC '96 window. This is useful if you wish to manipulate the main V96
  484. window, for example, the following code will hide ViRC '96:
  485.  
  486.         @p 0.Visible = False
  487.  
  488. Or you can add your own controls to ViRC '96's main window by setting their
  489. owner to 0, for example, the following code will add a button to the main V96
  490. window which quits V96 when you click on it:
  491.  
  492.         @ $mainbtn = $new(TButton ownedby 0)
  493.         With @p $mainbtn.
  494.              Left = 30
  495.              Top = 60
  496.              Width = 150
  497.              Height = 25
  498.              Caption = &Exit
  499.              OnClick = Exit
  500.         EndWith
  501.  
  502. Visual controls
  503. ===============
  504.  
  505. The following major visual controls are currently supported fully: TForm,
  506. TTabbedForm, TButton, TBitBtn, TListBox, TComboBox, TEdit, TMemo, TRichEdit,
  507. TCheckBox, TRadioButton, TGroupBox, TPanel, TBevel, TShape, TTrackBar,
  508. TProgressBar, TTabControl. Here I'll try to document some of the features of
  509. each object.
  510.  
  511. All objects
  512. -----------
  513.  
  514. The following properties are shared by all visual objects:
  515.  
  516.         Left            - X position of object
  517.         Top             - Y position of object
  518.         Width           - Width of object
  519.         Height          - Height of object
  520.         Visible         - (True or False) Controls whether object is visible
  521.         Enabled         - (True or False) Controls whether object is enabled
  522.         Color           - The background colour of the object
  523.         Font.Color      - The object's font colour
  524.         Font.Name       - The object's font name
  525.         Font.Size       - The object's font size
  526.         Font.Style      - (set) fsBold, fsItalic, fsUnderline, fsStrikeout
  527.         Hint            - The tooltip that appears if the user holds the mouse over the control for a while without clicking
  528.         ShowHint        - (True or False) Controls whether the tooltip is displayed or not
  529.         Align           - Causes the control to "stick" to one edge of its parent, or to fill the whole client area. alNone, alTop, alBottom, alLeft, alRight, alClient
  530.         Handle          - Returns the control's window handle (hWnd)
  531.  
  532. The following events are shared by all visual objects:
  533.  
  534.         OnClick         - Fired when object is clicked
  535.         OnMouseMove     - Fired when mouse moved over object
  536.         OnMouseDown     - Fired when mouse button pressed over object
  537.         OnMouseUp       - Fired when mouse button released over object
  538.         OnActivate      - Fired when the object gets the focus
  539.  
  540. Supported by most visual objects (where appropriate):
  541.  
  542.         OnChange        - Fired when object's selection (item, check mark, tab page, etc.) is changed
  543.  
  544. Methods:
  545.  
  546.         Repaint         - Causes the object, and all the objects it owns, to redraw themselves
  547.         SetFocus        - Sets focus to the object
  548.         BringToFront    - Brings the object to the front of the screen
  549.  
  550. Objects that introduce no additional properties or events will not be
  551. documented further - their usage should be self-explanatory!!
  552.  
  553. In addition, most objects have a standard BorderStyle property (except for the
  554. TForm), which can be bsNone for no border or bsSingle for a single black line
  555. border.
  556.  
  557. TForm
  558. -----
  559.  
  560. Properties:
  561.  
  562.         ActiveControl   - The control that has the focus when the form appears
  563.         BorderStyle     - bsSingle, bsDialog, bsNone, bsSizeable
  564.         FormStyle       - fsNormal, fsMDIForm, fsMDIChild, fsStayOnTop
  565.         Position        - poDefault, poScreenCenter
  566.         WindowState     - wsNormal, wsMaximized, wsMinimized
  567.         Caption         - The form's caption
  568.         BorderIcons     - (set) biSystemMenu, biMaximize, biMinimize
  569.  
  570.         OnClose         - Fired when the form is closed (it's a good idea to
  571.                           DESTROY the form here, otherwise it will stay in
  572.                           memory!!)
  573.  
  574. Events:
  575.  
  576.         OnResize        - Fired when the form's size is adjusted
  577.  
  578. TTabbedForm
  579. -----------
  580.  
  581. Exactly as above, except that a window tab (in the main V96 window) is made for
  582. the form. Adds one new property:
  583.  
  584.         TabCaption      - The caption of the window's tab
  585.  
  586. TButton
  587. -------
  588.  
  589. Properties:
  590.  
  591.         Caption         - The button's caption
  592.  
  593. Note that the Font.Style property is ignored on a TButton. Use a TBitBtn
  594. instead if you wish to change the Font.Style property.
  595.  
  596. TBitBtn
  597. -------
  598.  
  599. As above, only Font.Style can be set, for example:
  600.  
  601.         @p $bitbtn.Font.Style = [fsBold,fsUnderline]
  602.  
  603. Button bitmaps are supported by TBitBtn but not by ObjectViRCScript (go
  604. figure). Bitmaps should be supported shortly.
  605.  
  606. TListBox and TComboBox
  607. ----------------------
  608.  
  609. Properties:
  610.  
  611.         Items           - A TStringList object containing all the items
  612.         ItemText        - The text of the currently-selected item (or empty if no item selected)
  613.         ItemIndex       - The index of the currently-selected item (or -1 if no item selected)
  614.  
  615. See later in this file under "Non-visual controls" for information on how to
  616. manipulate a TStringList object.
  617.  
  618. TEdit, TMemo, TRichEdit
  619. -----------------------
  620.  
  621. Properties:
  622.  
  623.         Text            - Contains the text in the edit control
  624.         SelStart        - The start of the text selection
  625.         SelLength       - The length of the text selection (0 if nothing selected)
  626.         SelText         - The selected text
  627.         ReadOnly        - (True or False) Controls whether the text control is
  628.                           read-only (not modifiable by the user)
  629.         WordWrap        - (TMemo and TRichEdit only) Controls whether words are
  630.                           wrapped on multiple lines
  631.         Lines           - (TMemo and TRichEdit only) TStringList object that
  632.                           contains the lines of text in the control (see
  633.                           the "Non-visual controls" section below for
  634.                           information on TStringList)
  635.  
  636. In general, you should use TEdit for single lines of text and TRichEdit for
  637. multiple lines (in colour if necessary). You should never have to use TMemo,
  638. which is the same as TRichEdit except you cannot output text with
  639. TextOut > %$object (see VSCRIPT.TXT under TEXTOUT for more information on
  640. this).
  641.  
  642. TCheckBox, TRadioButton
  643. -----------------------
  644.  
  645. Properties:
  646.  
  647.         Checked         - Whether or not the control is checked
  648.         Caption         - The caption on the check box or radio button
  649.  
  650. TGroupBox
  651. ---------
  652.  
  653. Properties:
  654.  
  655.         Caption         - The group box's caption
  656.  
  657. TPanel
  658. ------
  659.  
  660. Properties:
  661.  
  662.         Caption         - The text within the panel
  663.         Alignment       - Text alignment. taCenter, taLeft, taRight
  664.         BevelInner      - The inner bevel. bvNone, bvLowered, bvRaised
  665.         BevelOuter      - The inner bevel. bvNone, bvLowered, bvRaised
  666.         BevelWidth      - The width of the bevel
  667.  
  668. TBevel
  669. ------
  670.  
  671. Properties:
  672.  
  673.         Style           - The bevel's style. bsLowered, bsRaised
  674.         Shape           - The bevel's shape. bsBox, bsFrame, bsTopLine, bsBottomLine, bsLeftLine, bsRightLine
  675.  
  676. TTrackBar
  677. ---------
  678.  
  679. Properties:
  680.  
  681.         Min             - The minimum value of the track bar
  682.         Max             - The maximum value of the track bar
  683.         Position        - The track bar's position
  684.         Orientation     - trHorizontal, trVertical
  685.  
  686. TProgressBar
  687. ------------
  688.  
  689. Properties:
  690.  
  691.         Min             - The minimum value of the progress bar
  692.         Max             - The maximum value of the progress bar
  693.         Position        - The progress bar's position
  694.  
  695. TTabControl (tabbed notebook)
  696. -----------------------------
  697.  
  698. Properties:
  699.  
  700.         Tabs            - TStringList containing all the tabs in the tabbed
  701.                           notebook
  702.         TabIndex        - The number of the currently selected tab. -1 means
  703.                           no tab selected, 0 means the first tab is selected,
  704.                           1 the second, etc.
  705.  
  706. For information on how to use the TStringList object, see the "Non-visual
  707. controls" section.
  708.  
  709. Non-visual controls
  710. ===================
  711.  
  712. TStringList (string list object)
  713. --------------------------------
  714.  
  715. The TStringList is a very powerful object. It can store a list of strings,
  716. which can be saved to and from disk, sorted, and manipulated in a powerful
  717. manner, rather like a sophisticated string array. TStringList objects are
  718. used internally by TListBox, TComboBox, TTabControl etc. to maintain their
  719. list of items. Strings start at index 0. TStringList objects grow and shrink
  720. automatically to store all the strings.
  721.  
  722. Properties:
  723.  
  724.         Count                   - The number of strings in the list
  725.  
  726. Methods:
  727.  
  728.         GetString(i)            - Gets the string at index i
  729.         SetString i text        - Sets the string at index i to text
  730.         Add(text)               - Adds a string, returns the index
  731.         Delete i                - Deletes the string at index i, moves the others up by one
  732.         Clear                   - Clears the string list
  733.         Exchange i j            - Exchanges the string at position i with the string at position j
  734.         SaveToFile file         - Saves the string list to file
  735.         LoadFromFile file       - Loads the string list from file
  736.         SaveToSet()             - Converts the string list to a set (e.g. [one,two,three]) and returns the set
  737.         LoadFromSet set         - Clears the string list and adds each element in the set to the string list
  738.         Sort                    - Alphabetically sorts the strings in the string list
  739.  
  740. TSockets (Winsock socket control)
  741. ---------------------------------
  742.  
  743. ViRC '96 0.82 and above support a TSockets class, whose interface is similar
  744. to the freeware Sockv3 Delphi control. Anyone who has used this will feel
  745. instantly familiar!!
  746.  
  747. Nothing has been changed in TSockets in 0.82a, however, MANY documentation
  748. inaccuracies in this section have been fixed, so please read through this
  749. again, even if you thought you understood it for 0.82!!
  750.  
  751. Note that, unlike every other non-visual object, TSockets _REQUIRES_ an owner.
  752. You cannot use a TSockets without a TForm to own it. If you wish to use a
  753. TSockets without an accompanying form you can either set the TSockets's owner
  754. to 0, i.e. $new(TSockets ownedby 0) to make ViRC '96 itself own the TSockets,
  755. or you can create an invisible TForm to own the socket.
  756.  
  757. Properties:
  758.  
  759.         IPAddr          - The host name or IP address of where to connect to
  760.         Port            - The port to connect to or listen on
  761.  
  762. Methods:
  763.  
  764.         SConnect        - Connects to IPAddr:Port
  765.         SListen         - Listens for connections on Port
  766.         SAccept         - Accepts an incoming connection
  767.         SCancelListen   - Cancels a previous SListen command
  768.         Send text       - Sends text to the remote end
  769.         SendCRLF text   - Sends text plus a CRLF to the remote end
  770.  
  771. Events:
  772.  
  773.         OnSessionConnected      - Called after SConnect when session connects
  774.         OnSessionAvailable      - Called after SListen when an incoming connection arrives
  775.         OnSessionClosed         - Called when the remote end closes the connection
  776.         OnDataAvailable         - Called when data, sent by the remote end, is available for reception
  777.         OnErrorOccurred         - Called when a socket error occurs
  778.  
  779. Connecting somewhere
  780. --------------------
  781.  
  782. To connect somewhere, first create the socket, ownedby a form (this is VERY
  783. important, the socket WILL NOT WORK if it is not owned by anything). Then set
  784. the IPAddr property to the name or IP of the host you wish to connect to, and
  785. set Port to the port. Then call the SConnect method. Example:
  786.  
  787.         @ $socketform = $new(TForm)
  788.         @ $socket = $new(TSockets ownedby $socketform)
  789.  
  790.         @p $socket.IPAddr = post.demon.co.uk
  791.         @p $socket.Port = 25
  792.         $socket.SConnect
  793.  
  794. Listening for connections
  795. -------------------------
  796.  
  797. Virtually identical to the above, except that IPAddr isn't specified and you
  798. call SListen instead of SPort. For example, to listen for incoming connections
  799. on port 1234, do:
  800.  
  801.         @ $socketform = $new(TForm)
  802.         @ $socket = $new(TSockets ownedby $socketform)
  803.  
  804.         @p $socket.Port = 1234
  805.         $socket.SListen
  806.  
  807. Accepting incoming connections
  808. ------------------------------
  809.  
  810. When you are listening and an incoming connection comes in, the
  811. OnSessionAvailable event is fired. You can then use the SAccept method to
  812. accept the connection. Example:
  813.  
  814.         @p $socket.OnSessionAvailable = SOCKET_INCOMING
  815.  
  816.         Alias SOCKET_INCOMING
  817.           $socket.SAccept
  818.         EndAlias
  819.  
  820. When the remote end connects
  821. ----------------------------
  822.  
  823. After you have issued the SConnect call, V96 tries to connect with the remote
  824. host. When a connection is established, the OnSessionConnected event is fired.
  825. You must not send data to the socket before this event is fired!! Example:
  826.  
  827.         @p $socket.OnSessionConnected = SOCKET_CONNECTED
  828.  
  829.         Alias SOCKET_CONNECTED
  830.           TextOut > . clBlue *** We're connected!!
  831.         EndAlias
  832.  
  833. Socket errors
  834. -------------
  835.  
  836. If the socket fails, either while attempting to connect or during data transfer
  837. and so forth, the OnErrorOccurred event is fired:
  838.  
  839.         @p $socket.OnErrorOccurred = SOCKET_ERROR
  840.  
  841.         Alias SOCKET_ERROR
  842.           TextOut > . clRed *** Error occurred while using socket!!
  843.         EndAlias
  844.  
  845. Note that "Connection reset by peer" (which occurs when a client closes a
  846. connection with a server) is treated as an error. By default, all errors will
  847. shut V96 down (I will endeavour to change this behaviour in future releases).
  848. Therefore it is STRONGLY recommended you have the following statement in:
  849.  
  850.         @p $socket.OnErrorOccurred = Nop
  851.  
  852. NOP simply does nothing - this ensures that your application will continue
  853. whenever a socket error occurs.
  854.  
  855. Sending data
  856. ------------
  857.  
  858. Data is sent with the SEND or SENDCRLF methods, which are identical except for
  859. that fact that SENDCRLF sends a CRLF at the end of the line, whereas SEND does
  860. not. Usually, you will use SENDCRLF. Example, which sends the string "Hello!!"
  861. after connecting to the host:
  862.  
  863.         @p $socket.OnSessionConnected = SOCKET_CONNECTED
  864.  
  865.         Alias SOCKET_CONNECTED
  866.           $socket.SendCRLF Hello!!
  867.         EndAlias
  868.  
  869. Receiving data
  870. --------------
  871.  
  872. When data is received on the socket, the OnDataAvailable event is fired. You
  873. can receive the data by reading the socket's Text property. Note that reading
  874. the Text property REMOVES THE DATA FROM THE SOCKET'S QUEUE. RETRIEVING ITS
  875. VALUE AGAIN WILL CAUSE AN ERROR!! Therefore assign the value of the Text
  876. property to a variable at the beginning of the event code, and only reference
  877. that variable. Example, which sends "Good morning!!" back whenever "Hello!!"
  878. is received:
  879.  
  880.         @p $socket.OnDataAvailable = SOCKET_DATA
  881.  
  882.         Alias SOCKET_DATA
  883.           @ $data = $prop($socket.Text)
  884.           if ([$data] == [Good morning!!])
  885.              $socket.SendCRLF Hello!!
  886.           endif
  887.         EndAlias
  888.  
  889. Closing the connection
  890. ----------------------
  891.  
  892. The socket connection can be closed with the SClose method, for example, this
  893. closes the connection when QUIT is received:
  894.  
  895.         @p $socket.OnDataAvailable = SOCKET_DATA
  896.  
  897.         Alias SOCKET_DATA
  898.           @ $data = $prop($socket.Text)
  899.           if ([$data] == [QUIT])
  900.              $socket.SClose
  901.           endif
  902.         EndAlias
  903.  
  904. When the REMOTE END closes the connection, the OnSessionClosed event is fired.
  905. You must close the local end of the socket with SClose when this event is
  906. fired. You could do something like this:
  907.  
  908.         @p $socket.OnSessionClosed = $socket.SClose
  909.  
  910. Cancelling listening
  911. --------------------
  912.  
  913. If you're listening on a port and wish to cancel listening, call the
  914. SCancelListen method. This listens on port 1234 and cancels listening when
  915. an incoming connection appears:
  916.  
  917.         @p $socket.Port = 1234
  918.         @p $socket.OnSessionAvailable = SOCKET_AVAILABLE
  919.         $socket.SListen
  920.  
  921.         Alias SOCKET_AVAILABLE
  922.           $socket.SAccept
  923.           TextOut > . clBlue *** We're connected!!
  924.           $socket.SCancelListen
  925.         EndAlias
  926.  
  927. TTimer
  928. ------
  929.  
  930. Timer creation is very simple, just use a TTimer object. First create the
  931. object, set the Interval property for the time interval, set the OnTimer event
  932. to the code you want executed every Interval milliseconds, and set Enabled to
  933. True to turn the timer on.
  934.  
  935. Properties:
  936.  
  937.         Enabled         - (True or False) Controls whether the timer is enabled or not
  938.         Interval        - The interval in milliseconds between the firing of the OnTimer event
  939.  
  940. Events:
  941.  
  942.         OnTimer         - This event is fired when the timer goes off (every Interval milliseconds)
  943.  
  944. Example:
  945.  
  946.         @ $timer = $new(TTimer)
  947.         @p $timer.Interval = 1000
  948.         @p $timer.OnTimer = BEEP
  949.         @p $timer.Enabled = True
  950.  
  951. This will beep every second. How unspeakably annoying!!
  952.